<template>
  <div>
    <a-radio v-model:checked="checked">Radio</a-radio>
    <a-button type="primary" ghost @click="proxy.$goTo('Home')">返回首页</a-button>
    我是测试页面
  </div>
</template>

<script setup lang="ts">
import { ref, defineProps, getCurrentInstance, ComponentInternalInstance } from 'vue';
import { useRouter } from 'vue-router';
import XEUtils from 'xe-utils';
import actions from '@/micro/shared/actions';

// 路由
const router = useRouter();

//子应用接受数据
actions.onGlobalStateChange((state, prevState) => {
  console.log('父应用获取的参数', state, prevState);
  // state: 变更后的状态; prevState: 变更前的状态
  console.log('主应用观察者：token 改变前的值为 ', prevState.token);
  console.log('主应用观察者：登录状态发生改变，改变后的 token 的值为 ', state.token);
});
actions.setGlobalState({ key: 'key', value: { name: 1 }, token: 'eeedddfff' });

//全局方法使用
const { proxy }: any = getCurrentInstance();

//深拷贝
let obj = {
  name: 1
};
let obj2 = XEUtils.clone(obj);
obj.name = 2;

// console.log('环境变量',import.meta.env.BASE_URL,import.meta.env);
// store.dispatch(`common/${types.ISLOADING}`,true)

const count = ref(0);

const checked = ref<boolean>(false);
</script>

<style lang="less" scoped></style>
